{% extends "xadmin/base_site.html" %}
{% load static %}
{# 导入 样式#}
{% block extrastyle %}
    <link rel="stylesheet" href="{% static 'style.css' %}">
{% endblock %}
{# 这个是原来的数据筛选div #}
{% block content-nav %}
{% endblock %}

{% block content %}
{#    导航栏 start #}
<nav class="navbar navbar-default navbar-static-top">
  <div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav nav-tabs nav-justified">
        <li><a href="{% url 'xadmin:meetingSetting' %}?id={{ meeting_id }}">参与学生 <span class="sr-only">(current)</span></a></li>
        <li><a href="{% url 'xadmin:importStudent' %}?id={{ meeting_id }}">不符合资格学生</a></li>
{#          //href="{% url 'xadmin:importStudent' %}?id={{ meeting_id }}"#}
        <li><a href="{% url 'xadmin:importStudentGrade' %}?meeting_id={{ meeting_id }}">导入学生成绩</a></li>

        <li class="active"><a href="{% url 'xadmin:juryList' %}?meeting_id={{ meeting_id }}">评委列表</a></li>
        <li><a href="{% url 'xadmin:allotJury' %}?meeting_id={{ meeting_id }}">分配评委</a></li>
{#        <li><a href="javascript:;">会议统计</a></li>#}
      </ul>

    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
    {#    导航栏 end #}
<div class="content-bottom">
    <!-- 操作 -->
    <div class="content-bottom-top">
        <div class="center-div" style="margin-bottom: 0px; width: 100%;">

            <div style="margin-top: 20px;">
                <div style="float: left; margin-right: 10px; margin-bottom: 30px; margin-top: 8px; {% if meeting.gradeStatus == "已结束" %} display:none {% endif %}" >
                    <button class="btn btn-primary btn_setting allocated-account" data-toggle="modal"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span>&nbsp; 分配账户</button>
                </div>
{#                <div style="float: left; margin-right: 10px; margin-bottom: 30px; margin-top: 8px; {% if meeting.gradeStatus == "已结束" %} display:none {% endif %}" >#}
{#                    <button class="btn btn-primary btn_setting add-jury" data-toggle="modal" data-target="#myModal"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span>&nbsp; 添加</button>#}
{#                </div>#}
{#                <div class="del" style="float: left; margin-bottom: 30px; margin-top: 8px; {% if meeting.gradeStatus == "已结束" %} display:none {% endif %}">#}
{#                    <button class="btn btn-primary btn_setting delete-jury"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span>&nbsp; 删除</button>#}
{#                </div>#}
                <div class="del" style="float: left; margin-bottom: 30px; margin-top: 8px; {% if meeting.gradeStatus == "已结束" %} display:none {% endif %}">
                    <button class="btn btn-primary btn_setting export-jury"><span class="glyphicon glyphicon-export" aria-hidden="true"></span>&nbsp; 导出表格</button>
                </div>
                <div class="count" style="margin-top: 20px;">
                    <span> 共有评委: <span style="color: #1b9dec; margin-right: 20px;">{{ jury_list | length }}</span>  </span>
                </div>
            </div>

        </div>
    </div>
    <!-- 学生列表 -->
    <div class="content">
        <table class="table table-hover table-bordered table-striped table-advance" >
        <thead>
            <tr>
              <th style="{% if meeting.gradeStatus == "已结束" %} display:none {% endif %};"><input type="checkbox" style="margin-left: 19px;" class="checkboxAll"></th>
              <th>评委姓名</th>
              <th>评委账户</th>
              <th>评委密码</th>
{#              <th>是否提交</th>#}
            </tr>
        </thead>
        <tbody>
        {% for jury in jury_list %}
            <tr >
                <td style="{% if meeting.gradeStatus == "已结束" %} display:none {% endif %};"><input class="checkbox" type="checkbox" name="item" value="{{ jury.id }}"></td>
                <td>{{ jury.jname }}</td>
                <td>{{ jury.jno }}</td>
                <td>{{ jury.password }}</td>
{#                <td><span {% if jury.all_status == "已提交" %} style="color:#2E8B57 " {% elif jury.all_status == "未提交" %}style="color:#CD3700 "{% endif %}>{{ jury.all_status }}</span></td>#}
            </tr>
        {% empty %}
            <tr>
                <td style="{% if meeting.gradeStatus == "已结束" %} display:none {% endif %};">暂无内容</td>
                <td>暂无内容</td>
                <td>暂无内容</td>
                <td>暂无内容</td>
{#                <td>暂无内容</td>#}
            </tr>
        {% endfor %}
        </tbody>
        </table>
    </div>
</div>
<!-- 添加 模态框 start -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">添加</h4>
      </div>
      <div class="modal-body" style="padding-top: 0px;">
        <div class="top">
            <ul style="display: inline; list-style-type: none; margin-top: -10px;">
                <li style="display: inline-block"><button class="btn btn-primary btn_setting add-student"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span>&nbsp; 添加</button></li>
                <li style="display: inline-block">
{#                    <form class="navbar-form navbar-left" action="{% url "xadmin:meetingSetting" %}" method="get">#}
                        <div class="input-group search-group" style="top:16px;">
                         <span class="input-group-btn" style="display: none"><a class="btn btn-default" href="javascript:;">x</a></span>
                         <input  type="text" name="id" class="meeting_id" value="{{ meeting_id }}" hidden>
                         <input id="searchbar2" class="form-control addsearch-text" type="text" name="q" value="" placeholder="搜索 姓名或学号">
                        <span class="input-group-btn"><button class="btn btn-primary add-search" type="submit"><i class="fa fa-search"></i></button></span>
                        </div>
{#                    </form>#}
                </li>
            </ul>
        </div>
        <div class="student-list">
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>
<div class="addStudent" style="display: none">

    <div class="add-content">

    </div>

</div>
<!-- 添加 模态框 end -->
<script>
    window.changehousts = "{% url "xadminData:meetingAddStudent" %}"
    csrf_token = "{{ csrf_token }}"
    {#    复选框全选#}
    $('.checkboxAll').click(function () {

        {#if($(".checkboxAll").attr("checked")){#}

            // 进行全选
            $("[name=item]:checkbox").prop("checked", this.checked)


    })
    {#// 导出表格 #}
    $('.export-jury').click(function () {
        var meeting_id = $(".meeting_id").val();
        window.location.href = "{% url 'xadminData:ExportAccount' %}?meeting_id="+meeting_id;
    })

    // 分配账户
    $(".allocated-account").click(function () {
        var checkedVal = [];
        var count = $("input:checkbox:checked").length
        if(count>0){
            $("[name=item]:checkbox:checked").each(function () {
                if($(this).val() != "on"){
                    checkedVal.push($(this).val());
                }
            })
            $.ajax(
                {
                    url: "{% url 'xadminData:allotAccount' %}",
                    type: "post",
                    cache: false,
                    data: {"juryId": JSON.stringify(checkedVal),csrfmiddlewaretoken:'{{ csrf_token }}'},
                    success: function (data) {
                        if(data.status == "成功"){
                            window.location.reload();
                        }else {
                            alert("失败")
                        }
                    },
                    error: function (xhr) {
                        console.log("出现问题")

                    }
                }
            )
        }else {
            alert("请至少选择一个")
        }
    })
</script>
{% endblock %}